#!/bin/bash

WAR_NAME="model-cms"
ONLINE_DIR=/usr/local/tomcat/webapps

mvn clean package -P online

hosts=(112.74.109.193)
for host in ${hosts[@]}
do
    scp -r target/$WAR_NAME.war root@$host:$ONLINE_DIR
    ssh root@$host "source /etc/profile;cd $ONLINE_DIR;rm -rf bak.ROOT && mv -f ROOT bak.ROOT;unzip $WAR_NAME.war -d ROOT; rm -rf $WAR_NAME.war $WAR_NAME; ./restart.sh"
    echo "$host is pubish OK...."
done
